package Day28;

import java.util.*;

class Node {

    int val;
    Node next;

    public Node (int val) {
        this.val = val;
        this.next = null;
    }

}

public class Main {

    public static void main (String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        //根结点
        Node root = new Node(in.nextInt());
        Node cur = root;
        //cur的下一个结点
        Node Next = null;

        //lastNode:存储最后反转的Node
        Node lastNode = null;
        Node nextNext = null;

        if (n == 1) {
            System.out.print(root.val);
            return;
        }

        for (int i = 1; i < n; i++) {
            Node nextNode = new Node(in.nextInt());
            cur.next = nextNode;
            cur = nextNode;
        }

        int L = in.nextInt();
        int R = in.nextInt();

        //frontNode:存储子链表的前面一个Node
        Node frontNode = root;

        cur = root;
        //c表示计数
        int c = 1;
        while (c != L) {
            if (cur != root) {
                frontNode = cur;
            }
            cur = cur.next;
            c++;
        }

        //c==1表示从头结点开始 所以没有frontNode
        if (c == 1) {
            frontNode = null;
        }

        //反转L到R的链表, 并获得最开始的firstNode和最后的lastNode
        //要让frontNode指向lastNode
        //      有frontNode:frontNode指向lastNode, 然后root不变
        //      没有frontNode:root = lastNode
        //让firstNode指向nextNext

        Next = cur.next;
        Node firstNode = cur;
        while (c != R) {

            if (Next != null) {
                nextNext = Next.next;
            } else {
                break;
            }

            Next.next = cur;
            cur = Next;
            Next = nextNext;

            c++;
        }
        lastNode = cur;

        if (frontNode != null) {
            frontNode.next = lastNode;
        } else {
            root = lastNode;
        }

        firstNode.next = nextNext;

        for (int i = 0; i < n - 1; i++) {
            System.out.print(root.val + " ");
            root = root.next;
        }
        System.out.print (root.val);
    }

}